#include <iostream>
#include <cmath>
using namespace std;

int main() {
    int t,money;
    string jiaji;
    cin >> t >> jiaji;

    if (t <= 1000) {
        money = 8;
    } else {
        money = 8 + ceil((double(t)-1000)/500)*4;
    }
    if (jiaji == "y")
    {
        money += 5;
    }
    if (t == 0)
    {
        money = 0;
    }
    cout << money;
    
    return 0;
}